#include <bits/stdc++.h>

std::array<int, 3> get(const std::vector<int> &a, int k) {
    const int n = a.size();
    int lo = 1, hi = n;
    std::vector<int> pre(n + 1);
    int L = 0, R = n;
    while (lo < hi) {
        int x = (lo + hi + 1) / 2;
        for (int i = 0; i < n; i++) {
            pre[i + 1] = pre[i] + (a[i] >= x ? 1 : -1);
        }
        
        int min = 0;
        bool ok = false;
        int L0 = 0;
        int R0 = 0;
        for (int i = k; i <= n; i++) {
            if (pre[i - k] < min) {
                min = pre[i - k];
                L0 = i - k;
            }
            if (pre[i] >= min) {
                ok = true;
                R0 = i;
                break;
            }
        }
        if (ok) {
            lo = x;
            L = L0;
            R = R0;
        } else {
            hi = x - 1;
        }
    }
    return {lo, L, R};
}

void solve() {
    int n, k;
    std::cin >> n >> k;
    
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    auto [max, l1, r1] = get(a, k);
    std::cout << max << " " << l1 + 1 << " " << r1 << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}
